/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main_com.Controlers.massage;

import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import main_com.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;

/**
 * @author Administrator
 */
@Controller
@RequestMapping("/lookMessageController")
public class LookMessageController extends HttpServlet {
    @Autowired
    UserMapper userMapper;

    @RequestMapping("/lookMessage")
    protected void lookMessage(HttpServletRequest request, HttpServletResponse response) {
        String userName = request.getParameter("userName");
        try {
            HttpSession session = request.getSession();
            ArrayList wordlist = userMapper.getMessageBeansByUserName(userName);
            session.setAttribute("wordlist", wordlist);
            response.sendRedirect("http://localhost/lookMessage/lookMessage.jsp");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
